<?php

/**
 * UploadedMaterial form base class.
 *
 * @method UploadedMaterial getObject() Returns the current form's model object
 *
 * @package    Amman to London
 * @subpackage form
 * @author     Adel Abu-Saif <adeljas@msn.com>
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseUploadedMaterialForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'local_file'    => new sfWidgetFormInputText(),
      'url'           => new sfWidgetFormInputText(),
      'file_name'     => new sfWidgetFormInputText(),
      'description'   => new sfWidgetFormTextarea(),
      'material_type' => new sfWidgetFormChoice(array('choices' => array('course pack' => 'course pack'))),
      'author'        => new sfWidgetFormInputText(),
      'faculty'       => new sfWidgetFormInputText(),
      'university'    => new sfWidgetFormInputText(),
      'created_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'local_file'    => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'url'           => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'file_name'     => new sfValidatorString(array('max_length' => 255)),
      'description'   => new sfValidatorString(),
      'material_type' => new sfValidatorChoice(array('choices' => array(0 => 'course pack'), 'required' => false)),
      'author'        => new sfValidatorString(array('max_length' => 255)),
      'faculty'       => new sfValidatorString(array('max_length' => 255)),
      'university'    => new sfValidatorString(array('max_length' => 255)),
      'created_at'    => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('uploaded_material[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'UploadedMaterial';
  }

}
